﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using nRoute.Components;
using nRoute.Samples.SquareAway.Model;
using nRoute.Samples.SquareAway.ViewModels;

namespace nRoute.Samples.SquareAway
{
    public partial class MainPage : PhoneApplicationPage
    {
        private static readonly SolidColorBrush BLUE_BRUSH = new SolidColorBrush(Color.FromArgb(255, 83, 114, 255));
        private static readonly SolidColorBrush GREEN_BRUSH = new SolidColorBrush(Color.FromArgb(255, 54, 255, 0));
        private static readonly SolidColorBrush ORANGE_BRUSH = new SolidColorBrush(Color.FromArgb(255, 255, 162, 0));
        private static readonly SolidColorBrush PURPLE_BRUSH = new SolidColorBrush(Color.FromArgb(255, 255, 63, 251));
        private static readonly SolidColorBrush RED_BRUSH = new SolidColorBrush(Color.FromArgb(255, 255, 0, 15));
        private static readonly SolidColorBrush DEFAULT_BRUSH = new SolidColorBrush(Colors.Black);
        
        public MainPage()
        {
            InitializeComponent();

            this.SetRelayConverter<SquareColor, SolidColorBrush>("SquareColorConverterRelay", (c) =>
            {
                switch (c)
                {
                    case SquareColor.Blue: return BLUE_BRUSH;
                    case SquareColor.Green: return GREEN_BRUSH;
                    case SquareColor.Orange: return ORANGE_BRUSH;
                    case SquareColor.Purple: return PURPLE_BRUSH;
                    case SquareColor.Red: return RED_BRUSH;
                    default:
                        return DEFAULT_BRUSH;                        
                }
            });

            this.SetRelayConverter<PlayState, bool>("StartedStateConverterRelay", (p) => 
            {
                return (p == PlayState.Started);
            });
        }
    }
}